import { createRouter, createWebHistory, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Layout from '../layout/index.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Home',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: 'home',
        component: () => import( '../views/home/index.vue'),
        name: 'Home',
        meta: { title: '首页', icon: 'home', affix: true }
      }
    ]
  },
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: 'technology',
        component: () => import( '@/views/technology/index.vue'),
        name: 'Technology',
        meta: { title: '技术积累', icon: 'document', affix: true }
      },
      {
        path: 'problem',
        component: () => import( '@/views/problem/index.vue'),
        name: 'Problem',
        meta: { title: '问题总结', icon: 'static', affix: true }
      },
      {
        path: 'informalessay',
        component: () => import( '@/views/informalessay/index.vue'),
        name: 'Informalessay',
        meta: { title: '随笔', icon: 'static', affix: true }
      },
      {
        path: 'detail',
        component: () => import( '@/views/detail/index.vue'),
        name: 'Detail',
        meta: { title: '详情', icon: 'static', affix: true }
      },
    ]
  }
]

const router = createRouter({
  // history: createWebHistory(),
  history: createWebHashHistory(), // hash 模式
  routes
})

export default router
